import { GetPlayListDetail } from "apis/index";
import { convertUnit } from "utils/index";
Page({
  data: {
    id: "", //排行榜id
    isFixed: false,
    list: [],
    posterImg: "",
  },

  onLoad(options) {
    const { id } = options;
    this.setData({ id });
    this.getList();
  },
  onPullDownRefresh() {
    wx.stopPullDownRefresh();
  },
  onShareAppMessage() {},
  onScroll(e) {
    const scrollTop = convertUnit(e.detail.scrollTop, "pxToRpx");
    this.setData({
      isFixed: scrollTop >= 350,
    });
  },
  getList() {
    const { id } = this.data;
    GetPlayListDetail({ id }).then((res) => {
      console.log(res, "id---怕行帮");
      let { coverImgUrl, tracks } = res.playlist;
      this.setData({
        coverImgUrl: coverImgUrl,
        list: tracks || [],
      });
    });
  },
});
